package com.kingjw.kafka.interceptor;

import org.apache.kafka.clients.producer.ProducerInterceptor;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;

import java.util.Map;

/**
 * @Package: com.kingjw.kafka.interceptor
 * @ClassName: TimeInterceptor
 * @Author: 王坚伟
 * @CreateTime: 2021/10/27 11:35
 * @Description:
 */
public class TimeInterceptor implements ProducerInterceptor<String,String> {
    public void configure(Map<String, ?> configs) {

    }

    public ProducerRecord<String,String> onSend(ProducerRecord<String,String> record) {
        return new ProducerRecord<String,String>(record.topic(),record.partition(),record.timestamp(),
                record.key(),System.currentTimeMillis()+","+record.value().toString());
    }

    public void onAcknowledgement(RecordMetadata metadata, Exception exception) {

    }

    public void close() {

    }
}
